home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / yame.zip / YSAMPLES.PRG < prev   
Text File  |  1994-03-09  |  20KB  |  570 lines

  1. * YSamples.prg
  2. *
  3. * Sample application for YAME -- Yet Another Memo Editor
  4. *
  5. * by Kenneth Chan
  6. * Please refer to YAME.DOC for contacts
  7. *
  8. * 08/21/93
  9. *
  10.  
  11. use YSAMPLES
  12.  
  13. define popup uYAME from  7,26
  14. define bar 1 of uYAME prompt "  Single memo with .FMT "   message " WP option in CONFIG.DB "
  15. define bar 2 of uYAME prompt "  Multiple memo with .FMT " message " WP option in CONFIG.DB and YAMEPARM "
  16. define bar 3 of uYAME prompt "  .BIN invocation "         message " LOAD and CALL "
  17. define bar 4 of uYAME prompt "──────────────────────────" skip
  18. define bar 5 of uYAME prompt "  Last two rows problem "   message " Demonstrate problem with losing lines 23 and 24 "
  19. define bar 6 of uYAME prompt "  Last two rows solution  " message " Workaround for problem with losing lines 23 and 24 "
  20. define bar 7 of uYAME prompt "──────────────────────────" skip
  21. define bar 8 of uYAME prompt "  Go to dot prompt "        message " RETURN "
  22. define bar 9 of uYAME prompt "  Go to DOS        "        message " QUIT "
  23. on selection popup uYAME deactivate popup
  24. do while .t.
  25.   clear
  26.   @  4,34 say "YAME Samples"
  27.   @  3,26 to  5,53 double
  28.   activate popup uYAME
  29.   do case
  30.     case "Single" $ prompt()
  31.       do Fmt1
  32.     case "Multiple" $ prompt()
  33.       do Fmt2
  34.     case "BIN" $ prompt()
  35.       do BinInvoc
  36.     case "problem" $ prompt()
  37.       do RowsProb
  38.     case "solution" $ prompt()
  39.       do RowsSol
  40.     case "DOS" $ prompt()
  41.       quit
  42.     otherwise
  43.       exit
  44.   endcase
  45. enddo
  46. release popup uYAME
  47.  
  48. use in YSAMPLES
  49. RETURN
  50.  
  51.  
  52.  
  53. PROCEDURE Fmt1
  54.   set format to YSAMPLE1
  55.   *-- Goto record with memo formatted for this form.  In your applications,
  56.   *-- all your memos will be formatted the same, but in this demo file, there
  57.   *-- are different memos for the different implementations/margins.
  58.   goto 1                                && soft returns at 57 margin
  59.   edit next 1 nomenu
  60.   set format to
  61. RETURN
  62.  
  63.  
  64.  
  65. PROCEDURE Fmt2
  66.   set format to YSAMPLE2
  67.   load YAMEPARM
  68.   *-- Goto record with memo formatted for this form.
  69.   goto 2                                && soft returns at 37 margin
  70.   edit next 1 nomenu
  71.   *-- Uninstall YAMPARM by CALLing it with no parameters
  72.   call YAMEPARM
  73.   release module YAMEPARM
  74.   set format to
  75. RETURN
  76.  
  77.  
  78.  
  79. PROCEDURE BinInvoc
  80.   *-- Load YAME (note .COM extension)
  81.   load Y.COM
  82.   *-- Load edit buffer
  83.   load YAMEBUFF
  84.   *-- Init buffer with maximum allowed memo size.  65024 is maximum maximum.
  85.   call YAMEBUFF with 65024
  86.   *-- Goto record with memo formatted for this form.
  87.   goto 3                                && YAME native; no soft returns
  88.   clear
  89.   @  1, 1 say ".BIN invocation:  using the provided MemoKey() function, you can simulate the"
  90.   @  2, 1 say "standard key action for a memo field.  Here, there is one open window and one"
  91.   @  3, 1 say "memo marker.  The YAMEBUFF.BIN file must be loaded and initialized for the"
  92.   @  4, 1 say ".BIN invocation to work."
  93.   @  7, 0 to  7,79
  94.   @  8,27 say "Topic"
  95.   @  8,33 get TOPIC
  96.   @ 10,14 say "Argument FOR"
  97.   *-- Putting the memo marker one row down and one column to the right
  98.   *   ╔══════════════════════╗
  99.   *   ║memo                  ║
  100.   *   ║                      ║
  101.   *   ║                      ║
  102.   *   ╚══════════════════════╝
  103.   *-- of the window puts cursor at top left of the inside of the memo window
  104.   @ 12, 1 get ARG_PRO ;
  105.     when MemoKey( 11, 0, 19, 39, "/i19,1" )
  106.   *-- Display the contents of the open window
  107.   do DispMemo with "ARG_PRO", 11, 0, 19, 39
  108.   *-- For this field use a memo marker
  109.   @ 10,52 say "Argument AGAINST"
  110.   *-- by putting the memo field outside the window
  111.   @ 10,69 get ARG_CON ;
  112.     when MemoKey( 11, 40, 19, 79, "/i19,41" )
  113.   @ 22,28 say "by"
  114.   @ 22,31 get AUTHOR
  115.   read
  116.   *-- Uninstall YAMEBUFF with CALLing with no parameters
  117.   call YAMEBUFF
  118.   release module YAMEBUFF
  119.   *-- No separate uninstall for Y.COM; just RELEASE
  120.   release module Y
  121. RETURN
  122.  
  123.  
  124.  
  125. PROCEDURE RowsProb
  126.   clear
  127.   @  1, 0 to 23,79 176
  128.   *-- Goto record with memo formatted for this demo
  129.   goto 1
  130.   *-- Copy the memo field to a temp file to workaround abort READ anomaly
  131.   copy to ONEMEMO field ARG_CON next 1
  132.   use ONEMEMO in select()
  133.   @  4, 6 get TOPIC ;
  134.     message " Cursor down to the memo field "
  135.   @  6, 6 get ONEMEMO->ARG_CON ;
  136.     message " Press CTRL-HOME then press ESC.  Watch this line and the line above. "
  137.   @  8, 6 get AUTHOR ;
  138.     message " Cursor up to the memo field "
  139.   read
  140.   *-- If changes were made, copy memo back from temp file
  141.   if readkey() >= 256
  142.     replace ARG_CON with ONEMEMO->ARG_CON
  143.   endif
  144.   *-- Erase temp file(s)
  145.   use in ONEMEMO
  146.   erase ONEMEMO.DBF
  147.   erase ONEMEMO.DBT
  148. RETURN
  149.  
  150.  
  151.  
  152. PROCEDURE RowsSol
  153.   clear
  154.   @  1, 0 to 23,79 176
  155.   *-- Goto record with memo formatted for this demo
  156.   goto 1
  157.   *-- Copy the memo field to a temp file to workaround abort READ anomaly
  158.   copy to ONEMEMO field ARG_CON next 1
  159.   use ONEMEMO in select()
  160.   *-- State variable
  161.   public n_MemoScrn
  162.   *     0 == no checking
  163.   *     1 == initial entry into memo field
  164.   *     2 == grab next key
  165.   *     3 == screen saved
  166.   *-- Set state for initial entry into memo field
  167.   n_MemoScrn = 1
  168.   @  4, 6 get TOPIC ;
  169.     message " Cursor down to the memo field "
  170.   @  6, 6 get ONEMEMO->ARG_CON ;
  171.     when ForcValid() ;
  172.     valid required MemoScrn() ;
  173.     error "" ;
  174.     message " Press CTRL-HOME then press ESC.  Watch this line and the line above. "
  175.   @  8, 6 get AUTHOR ;
  176.     message " Cursor up to the memo field "
  177.   read
  178.   *-- If changes were made, copy memo back from temp file
  179.   if readkey() >= 256
  180.     replace ARG_CON with ONEMEMO->ARG_CON
  181.   endif
  182.   *-- Erase temp file(s)
  183.   use in ONEMEMO
  184.   erase ONEMEMO.DBF
  185.   erase ONEMEMO.DBT
  186.   *-- Release state variable
  187.   release n_MemoScrn
  188. RETURN
  189.  
  190.  
  191.  
  192. FUNCTION ForcValid
  193.   *----------------------------------------------------------------------------
  194.   *-- Programmer..: Kenneth Chan [Zak]  CIS:72662,1305
  195.   *-- Date........: 01/27/1993
  196.   *-- Notes.......: Workaround for losing last two lines on screen when
  197.   *                 using external memo editor.
  198.   *
  199.   *                 Forces a VALID check, activating MemoScrn()
  200.   *
  201.   *-- Written for.: dBASE IV, 1.5
  202.   *-- Rev. History: 01/27/1993 1.0
  203.   *-- Calls.......: Works in tandem with MemoScrn()
  204.   *                 The memvar n_MemoScrn must be defined, and should be
  205.   *                 set to 1 before the READ
  206.   *                     *-- State variable
  207.   *                     public n_MemoScrn
  208.   *                     *     0 == no checking
  209.   *                     *     1 == initial entry into memo field
  210.   *                     *     2 == grab next key
  211.   *                     *     3 == screen saved
  212.   *                     *-- Set state for initial entry into memo field
  213.   *                     n_MemoScrn = 1
  214.   *-- Called by...: WHEN clause of GET
  215.   *-- Usage.......: when ForcValid() valid required MemoScrn()
  216.   *-- Example.....: @ 6,11 get NOTES ;
  217.   *                   when ForcValid() ;
  218.   *                   valid required MemoScrn() ;
  219.   *                   error ""
  220.   *-- Returns.....: .T.
  221.   *-- Parameters..: <none>
  222.   *----------------------------------------------------------------------------
  223.   if n_MemoScrn = 1
  224.     *-- Move to next stage
  225.     n_MemoScrn = 2
  226.     *-- Trigger VALID check
  227.     keyboard "{CTRL-M}"
  228.     *-- Silence bell
  229.     set bell to 19,1
  230.   endif
  231.   if n_MemoScrn = 0
  232.     *-- Set state var for next memo field
  233.     n_MemoScrn = 1
  234.     *-- Restore bell to default tone
  235.     set bell to 512,2
  236.   endif
  237. RETURN .t.
  238.  
  239.  
  240.  
  241. FUNCTION MemoScrn
  242.   *----------------------------------------------------------------------------
  243.   *-- Programmer..: Kenneth Chan [Zak]  CIS:72662,1305
  244.   *-- Date........: 01/27/1993
  245.   *-- Notes.......: Workaround for losing last two lines on screen when
  246.   *                 using external memo editor.
  247.   *
  248.   *                 Works better when the ERROR message is set to
  249.   *                 nothing ("").
  250.   *
  251.   *-- Written for.: dBASE IV, 1.5
  252.   *-- Rev. History: 01/27/1993 1.0
  253.   *-- Calls.......: Works in tandem with ForcValid()
  254.   *                 The memvar n_MemoScrn must be defined
  255.   *                     *-- State variable
  256.   *                     public n_MemoScrn
  257.   *                     *     0 == no checking
  258.   *                     *     1 == initial entry into memo field
  259.   *                     *     2 == grab next key
  260.   *                     *     3 == screen saved
  261.   *-- Called by...: VALID REQUIRED clause of GET
  262.   *-- Usage.......: when ForcValid() valid required MemoScrn()
  263.   *-- Example.....: @ 6,11 get NOTES ;
  264.   *                   when ForcValid() ;
  265.   *                   valid required MemoScrn() ;
  266.   *                   error ""
  267.   *-- Returns.....: .T. eventually
  268.   *-- Parameters..: <none>
  269.   *----------------------------------------------------------------------------
  270.   private lRet, nKey
  271.   if n_MemoScrn > 1
  272.     if n_MemoScrn = 3
  273.       *-- Restore lines 23 and 24
  274.       restore screen from sMemoScrn
  275.       release screen sMemoScrn
  276.     endif
  277.     *-- Wait for keypress
  278.     nKey = inkey( 0 )
  279.     *-- Return VALID false to force next action to occur in
  280.     *-- current field
  281.     lRet = .f.
  282.     *-- Clear VALID error message
  283.     keyboard " "
  284.     *-- Ctrl-Home; edit memo
  285.     if nKey = 29
  286.       save screen to sMemoScrn
  287.       n_MemoScrn = 3
  288.       *-- Open memo and force recheck
  289.       keyboard "{CTRL-HOME}{CTRL-M}"
  290.     else
  291.       *-- Don't stop the next key
  292.       n_MemoScrn = 0
  293.       *-- Type the key that was trapped
  294.       keyboard "{" + ltrim( str( nKey )) + "}"
  295.     endif
  296.   else
  297.     *-- Pass key through
  298.     lRet = .t.
  299.     *-- Must init PRIVATE memvar
  300.     nKey = 0
  301.   endif
  302. RETURN lRet
  303.  
  304.  
  305.  
  306. PROCEDURE DispMemo
  307.   *----------------------------------------------------------------------------
  308.   *-- Programmer..: Kenneth Chan [Zak]  CIS:72662,1305
  309.   *-- Date........: 07/14/1993
  310.   *-- Notes.......: Displays a memo field in a window
  311.   *-- Written for.: dBASE IV, 1.5
  312.   *-- Rev. History: 07/14/1993 1.0
  313.   *-- Calls.......: <none>
  314.   *-- Called by...: <any>
  315.   *-- Usage.......: do DispMemo with <cMemoFld>, <nTop>, <nLft>, <nBtm>, <nRht>
  316.   *-- Example.....: do DispMemo with "NOTES", 5, 10, 18, 69
  317.   *-- Returns.....: <na>
  318.   *-- Parameters..: cMemoFld   = name of memo field
  319.   *                 nTop       = top row of window
  320.   *                 nLft       = left column of window
  321.   *                 nBtm       = bottom row of window
  322.   *                 nRht       = right column of window
  323.   *----------------------------------------------------------------------------
  324.   parameter cMemoFld, nTop, nLft, nBtm, nRht
  325.   private nOldWidth, n1
  326.   nOldWidth = set( "MEMOWIDTH" )
  327.   *-- Set MEMOWIDTH for window
  328.   set memowidth to nRht - nLft - 2
  329.   *-- Draw border
  330.   @ nTop, nLft to nBtm, nRht
  331.   @ nTop + 1, nLft + 1 clear to nBtm - 1, nRht - 1
  332.   n1 = 1
  333.   *-- Display each line
  334.   do while n1 < nBtm - nTop
  335.     @ nTop + n1, nLft + 1 say mline( &cMemoFld., n1 )
  336.     n1 = n1 + 1
  337.   enddo
  338.   set memowidth to nOldWidth
  339. RETURN
  340.  
  341.  
  342.  
  343. FUNCTION MemoKey
  344.   *---------------------------------------------------------------------
  345.   *-- Programmer..: Kenneth Chan [Zak]  CIS:72662,1305
  346.   *-- Date........: 03/09/1994
  347.   *-- Notes.......: Emulates standard behavior when cursor is on memo
  348.   *                 marker.  If Ctrl-Home or F9 is pressed, YAME is 
  349.   *                 CALLed.  Defaults to double border, and margins to
  350.   *                 fit in window.
  351.   *
  352.   *                 If memo field is inside window coordinates, memo is
  353.   *                 treated like an OPEN WINDOW.
  354.   *
  355.   *                 If memo window is inside a DEFINEd and ACTIVATEd
  356.   *                 WINDOW, specify the main (first set) of coordinates
  357.   *                 relative to that window, as you would the @ GET.
  358.   *                 Then specify the top left of the WINDOW, and if the
  359.   *                 border is NONE, indicate that as well.  For example:
  360.   *
  361.   *                   define window wEdit from  8,10 to 16,70
  362.   *                   activate window wEdit
  363.   *                   *-- Put the field marker inside the memo window
  364.   *                   @  2, 1 get MEMO_FIELD ;
  365.   *                     when MemoKey(  1, 0, 5, 39, "", "", 8, 10 )
  366.   *                   *-- Display the contents of the open window
  367.   *                   do DispMemo with "MEMO_FIELD", 1, 0, 5, 39
  368.   *
  369.   *                 Since YAME is CALLEed, YAMEBUFF must be LOADed and
  370.   *                 initialized (see YAME.DOC)
  371.   *
  372.   *-- Written for.: dBASE IV, 1.5
  373.   *-- Rev. History: 07/14/1993 1.0
  374.   *                 03/09/1994 1.1  Support for DEFINEd WINDOWs and
  375.   *                                 MESSAGEs
  376.   *-- Calls.......: Y.COM, (YAMEBUFF), DispMemo
  377.   *-- Called by...: WHEN clause of GET
  378.   *-- Usage.......: when MemoKey( <nTop>, <nLft>, <nBtm>, <nRht>, ;
  379.   *                   [ <cExtraParm> [, <cMessage> ;
  380.   *                   [, <nWinTop>, <nWinLft> [, <lNoBorder> ]]]] )
  381.   *-- Example.....: @ 6,11 get NOTES when MemoKey( 5, 10, 18, 69 )
  382.   *-- Returns.....: .T.
  383.   *-- Parameters..: nTop       = top row of window
  384.   *                 nLft       = left column of window
  385.   *                 nBtm       = bottom row of window
  386.   *                 nRht       = right column of window
  387.   *                 OPTIONAL:
  388.   *                 cExtraParm = extra parameters to pass to YAME
  389.   *                 cMessage   = message to display on MESSAGE line
  390.   *                 nWinTop    = top row of DEFINEd WINDOW
  391.   *                 nWinLft    = left column of DEFINEd WINDOW
  392.   *                 lNoBorder  = DEFINEd WINDOW border NONE?
  393.   *---------------------------------------------------------------------
  394.   parameters nTop, nLft, nBtm, nRht, cExtraParm, cMessage, ;
  395.     nWinTop, nWinLft, lNoBorder
  396.   *-- Make sure extra parameter is defined
  397.   if pcount() < 5
  398.     cExtraParm = ""
  399.   endif
  400.   *-- Make sure message text is defined
  401.   if pcount() < 6
  402.     cMessage = ""
  403.   endif
  404.   *-- If no DEFINEd WINDOW, top and left are 0, and no border
  405.   if pcount() < 8
  406.     nWinTop   = 0
  407.     nWinLft   = 0
  408.     lNoBorder = .t.
  409.   endif
  410.   private nRow, nCol, lLoop, cYAMEPARM, cMemoFld, cColorFld
  411.   *-- Construct YAME parameter string
  412.   cYAMEParm = "/m" + ltrim( str( nRht - nLft - 2 )) + " /@" + ;
  413.     ltrim( str( nTop + nWinTop + iif( lNoBorder, 0, 1 ))) + "," + ;
  414.     ltrim( str( nLft + nWinLft + iif( lNoBorder, 0, 1 ))) + "," + ;
  415.     ltrim( str( nBtm + nWinTop + iif( lNoBorder, 0, 1 ))) + "," + ;
  416.     ltrim( str( nRht + nWinLft + iif( lNoBorder, 0, 1 ))) + ;
  417.     " /bd " + cExtraParm + " MEMO_TMP.$DB"
  418.   cMemoFld = varread()
  419.   nRow = row()
  420.   nCol = col()
  421.   *-- Get the COLOR OF FIELDS
  422.   cColorFld = substr( set( "ATTRIBUTES" ), ;
  423.               rat( ",", set( "ATTRIBUTES" )) + 1 )
  424.   if file( "MEMO_TMP.$DB" )
  425.     erase MEMO_TMP.$DB
  426.   endif
  427.   copy memo &cMemoFld. to MEMO_TMP.$DB
  428.  
  429.   *-- Display message if there is one
  430.   if "" # cMessage
  431.     *-- MESSAGE memvars
  432.     private nBtmRow, cMsgColor, cWindow
  433.     *-- If memo window is in a WINDOW, we will need to ACTIVATE SCREEN
  434.     *-- for the messages
  435.     cWindow = window()
  436.     *-- and do it now to properly determine the MESSAGES color
  437.     if .not. isblank( cWindow )
  438.       activate screen
  439.     endif
  440.     *-- Figure out bottom row from DISPLAY SETting
  441.     nBtmRow = val( right( set( "DISPLAY" ), 2 ))
  442.     *-- Bottom row of MONO and COLOR is row 24
  443.     nBtmRow = iif( m->nBtmRow = 0, 24, m->nBtmRow - 1 )
  444.     *-- MESSAGES color is first one after ampersands
  445.     cMsgColor = set( "ATTRIBUTES" )
  446.     cMsgColor = substr( m->cMsgColor, at( "&", m->cMsgColor ) + 3 )
  447.     cMsgColor = left( m->cMsgColor, at( ",", m->cMsgColor ) - 1 )
  448.     *-- and it's always bright
  449.     if .not. "+" $ m->cMsgColor
  450.       cMsgColor = stuff( m->cMsgColor, at( "/", m->cMsgColor ), 0, "+" )
  451.     endif
  452.     *-- Clear the message line
  453.     @ m->nBtmRow, 0 clear to m->nBtmRow,79
  454.     *-- Display message centered
  455.     @ m->nBtmRow, 40 - ceiling( len( cMessage ) / 2 ) ;
  456.       say cMessage color &cMsgColor.
  457.     if .not. isblank( cWindow )
  458.       activate window &cWindow.
  459.     endif
  460.     *-- Move cursor back to memo marker
  461.     @ nRow, nCol say ""
  462.   endif
  463.  
  464.   lLoop = .t.
  465.   do while lLoop
  466.     nKey = inkey( 0 )
  467.     do case
  468.       case nKey = 29 .or. nKey = -8 && Ctrl-Home or F9
  469.         save screen to sMemoKey
  470.         *-- Invoke YAME; exit code returned in parameter string
  471.         call Y with cYAMEParm
  472.         restore screen from sMemoKey
  473.         release screen sMemoKey
  474.         *-- Check exit code to see if file was saved
  475.         if cYAMEParm = "0"
  476.           *-- Update memo field
  477.           append memo &cMemoFld. from MEMO_TMP.$DB overwrite
  478.         endif
  479.         *-- If memo marker is outside the window
  480.         if nRow < nTop .or. nRow > nBtm .or. nCol + 3 < nLft ;
  481.                                         .or. nCol > nRht
  482.           *-- Update the memo marker
  483.           @ nRow, nCol say iif( len( &cMemoFld. ) = 0, "memo", "MEMO" );
  484.                                                        color &cColorFld.
  485.         else
  486.           *-- Redisplay memo
  487.           do DispMemo with cMemoFld, nTop, nLft, nBtm, nRht
  488.         endif
  489.         *-- Overwrite exit code with original slash
  490.         cYAMEParm = stuff( cYAMEParm, 1, 1, "/" )
  491.         *-- Do not KEYBOARD Ctrl-Home
  492.         nKey = 0
  493.       case "," + ltrim( str( nKey )) + "," $ ;
  494.         ",1,3,4,5,6,9,13,17,18,19,23,24,27,-400,"
  495.         *-- These keys will move the cursor, let them pass
  496.       case nKey > 0 .and. nKey < 256
  497.         *-- Ignore all other non-function keys
  498.         nKey = 0
  499.       otherwise
  500.         *-- KEYBOARD function key to allow for ON KEY traps
  501.         keyboard "{" + ltrim( str( nKey )) + "}"
  502.         *-- Clear keyboard buffer in case no one wanted function key
  503.         nKey = inkey()
  504.         *-- but don't leave
  505.         nKey = 0
  506.     endcase
  507.     if nKey # 0
  508.       *-- Type key
  509.       keyboard "{" + ltrim( str( nKey )) + "}" clear
  510.       *-- Quit loop
  511.       lLoop = .f.
  512.     endif
  513.     *-- Move cursor back after possible memo redraw
  514.     @ nRow, nCol say ""
  515.   enddo
  516.  
  517.   *-- Clear the message if one was displayed
  518.   if "" # cMessage
  519.     if .not. isblank( cWindow )
  520.       activate screen
  521.     endif
  522.     @ m->nBtmRow, 0 clear to m->nBtmRow,79
  523.     if .not. isblank( cWindow )
  524.       activate window &cWindow.
  525.     endif
  526.     *-- Move cursor back to memo marker
  527.     @ nRow, nCol say ""
  528.   endif
  529.  
  530.   if file( "MEMO_TMP.$DB" )
  531.     erase MEMO_TMP.$DB
  532.   endif
  533. *-- Return .T. to read stuffed keystroke
  534. RETURN .t.
  535.  
  536.  
  537.  
  538. *-- If you don't have dBASE IV v2.0, here's a RAT() UDF
  539. FUNCTION RAt
  540. *-------------------------------------------------------------------------------
  541. *-- Programmer..: Jay Parsons (CIS: 70160,340)
  542. *-- Date........: 03/01/1992
  543. *-- Notes.......: Reverse "at", returns position a character string is last
  544. *--               AT in a larger string.
  545. *-- Written for.: dBASE IV
  546. *-- Rev. History: 03/01/1992 -- Original Release
  547. *-- Calls.......: None
  548. *-- Called by...: Any
  549. *-- Usage.......: Rat("<cFindStr>","<cBigStr>")
  550. *-- Example.....: ? Rat("Test","This is a Test string, with Test data")
  551. *-- Returns.....: Numeric value
  552. *-- Parameters..: cFindStr = string to find in cBigStr
  553. *--               cBigStr  = string to look in
  554. *-------------------------------------------------------------------------------
  555.  
  556.     parameters cFindstr, cBigstr
  557.     private nPos,nLen
  558.     nLen = len( cFindstr )
  559.     nPos = len( cBigstr ) - nLen + 1
  560.     do while nPos > 0
  561.         if substr( cBigstr, nPos, nLen ) = cFindstr
  562.             exit
  563.         else
  564.             nPos = nPos - 1
  565.         endif
  566.     enddo
  567.     
  568. RETURN max( nPos, 0 )
  569. *-- EoF: RAt()
  570.